home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / .bin / httpd / Solaris_1 / visit_html.pl < prev    next >
Perl Script  |  1996-02-29  |  12KB  |  258 lines

  1. #!./perl
  2.  
  3. # ------------------------------------------------------------
  4.  
  5. # visit_html.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  6. # This manages the main menu of the interface: the user is
  7. # guided to do one step after another.
  8.  
  9. # ------------------------------------------------------------
  10.  
  11. # Bugs and other fixes
  12.  
  13. # ------------------------------------------------------------
  14. ##############################################################################
  15. # CreatDefaultIndex: create a default index.html using _info file
  16. ##############################################################################
  17. sub CreateDefaultIndex
  18. {
  19.     local($old);
  20.  
  21.     $INDEXFILENAME = "$HomeDir/$HomeName";
  22.     unless (open (INDEXFILE, "> $INDEXFILENAME")) {
  23.         &PrintErr("NoCreation", $INDEXFILENAME);
  24.         #print "<H3><dd><img ALIGN=middle src=\"file:///tmp/httpd/.products/CDware/images/error.gif\">Cannot create $INDEXFILENAME</H3></dd><br>";
  25.     }
  26.  
  27.     if (-s $INFOFILENAME && open (INFOFILE, $INFOFILENAME)) {
  28.         $LINE=<INFOFILE>;
  29.         ($Company, $Description, $Platform, $ChosenCat, $WebSite, $Email) = split(/\^/, $LINE);
  30.         $Product=<INFOFILE>;
  31.         chop($Product);
  32.         chop($Product);
  33.         close (INFOFILE);
  34.     }
  35.     
  36.     $old = select(INDEXFILE);
  37.     #print "test\n";
  38.     $~ = INDEX_DEFAULT;
  39.     write;
  40.  
  41.     close(INDEXFILE);
  42.     select($old);
  43. }
  44.  
  45. ##############################################################################
  46. # main
  47. ##############################################################################
  48. $BASEDIR = $ENV{"DOCUMENT_ROOT"};
  49. require 'devinfo.pl';
  50. require 'tools.pl';
  51.  
  52. $HomeDir = &GetDevinfo("dir");
  53. $INFOFILENAME = $HomeDir . "/_info";
  54.  
  55. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  56.     read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
  57. } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
  58.     $request = $ENV{'QUERY_STRING'};
  59. }
  60. if (-s $INFOFILENAME && open (INFOFILE, $INFOFILENAME)) {
  61.     $LINE=<INFOFILE>;
  62.     ($Company, $Description, $Platform, $Cat, $WebSite, $Email, $HomeName) = split(/\^/, $LINE);
  63.     if ($HomeName eq "") {
  64.         $HomeName = "index.html";
  65.     }
  66.     close (INFOFILE);
  67. }
  68.  
  69. $~ = HEADER;
  70. write;
  71.  
  72. $request =~ s/%(..)/pack("c",hex($1))/ge;
  73. #print "request=$request<br>";
  74. #print "ARGV0=$ARGV[0]<br>";
  75. #if (@ARGV == 0 && $request eq "") {
  76.  
  77. if ($request eq "") {
  78.     #print "in case argv=0";
  79. } elsif ($request eq "default=Create") {
  80.     #print "bef CreateDefault<br>";
  81.     &CreateDefaultIndex();
  82. } else {
  83.     $OldHomeName=$HomeDir . "/" . $request;
  84.     if (-s $OldHomeName) {
  85.         if (!system("mv $OldHomeName $HomeDir/index.html")) {
  86.             system("cd $HomeDir;ln -s ./index.html $OldHomeName");
  87.         } else {
  88.             &PrintErr("NoCreation", "$HomeDir/index.html");
  89.         }
  90.     } else {
  91.         &PrintErr("NoExist", $OldHomeName);
  92.     }
  93. }
  94.  
  95.     unless (-s "$HomeDir/$HomeName") {
  96.         print "<h4>\n<app class=\"ImageLoopItem\" img=\"file:///tmp/httpd/.products/DEV/images/blinkingAlert\" ALIGN=middle pause=5000 width=56 height=49>Your \"$HomeName\" file is missing!</h4><ul>"
  97.         ,"<H3><IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif\">If you already have HTML pages, copy them in the <b>\"$HomeDir\"</b> directory, and then reload the current page (press the <IMG ALIGN=middle SRC=\"file:///tmp/httpd/.products/DEV/images/sreload.gif\"> button at the page bottom).<br>"
  98.         , "<IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif\">Otherwise, please press this button to create a default home page using the information you previously entered:"
  99.         , "<FORM method=\"post\"  ACTION=\"http://localhost:7999/cgi-bin/visit_html.pl?\"><input type=\"submit\" NAME=\"default\" VALUE=\"Create\" > </FORM></ul></H3>"
  100.     } else {
  101.         $~ = ADVICES;
  102.         write;
  103.         #print "<H2><IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/bullet_ball_pink.gif\"><a href=\"file://$HomeDir/$HomeName\">To test your main page and links</a></H2><br>";
  104.         #print "<ul><IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/finger.gif\">To change your pages, you need to edit the html files that you put in the \"$HomeDir\" directory. To do that, you can use a text editor to directly change the content of the file or one of the numerous tools that exist.";
  105.         #print "<p><IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/finger.gif\">If you visit your html pages, you can come back any time to the main menu of the Developer's Kit by using the \"Goto\" Menu.</ul><br>";
  106.         #print "<H2><IMG ALIGN=middle src=\"file:///tmp/httpd/.products/DEV/images/bullet_ball_pink.gif\"><a href=\"file:///tmp/httpd/.products/DEV/tips.html\">Help and tips for designing your insertion</a></H2></ul><br>";
  107.             ##print "<H2><li><a href=\"http://localhost:7999/cgi-bin/checklinks.pl\">To check automatically your links</a></H2><br>";
  108.     }
  109.  
  110.     $~ = FOOTER;
  111.     write;
  112.  
  113.     $~ = SUBPAGE;
  114.     write;
  115.  
  116.  
  117. ##############################################################################
  118. # formats
  119. ##############################################################################
  120. format HEADER =
  121. Content-type: text/html
  122.  
  123.  
  124. <html>
  125. <title>Developer's Kit - HTML Test</title>
  126. <body>
  127. <CENTER><h1>CDware Developer's Kit</h1></CENTER>
  128. <h4>Currently working with "@*
  129. $HomeDir
  130. " directory</h4>
  131. <p>
  132. <ol type=1>
  133. .
  134.  
  135. format FOOTER =
  136. </ol>
  137. <h4><IMG src="file:///tmp/httpd/.products/DEV/images/bullet_ball_red.gif"><a href="http://localhost:7999/cgi-bin/mainmenu.pl?">To go back to the main menu</a></h4><br>
  138. <hr>
  139. <p>
  140. You, like these companies, will benefit from the CDware capability of reaching tens of thousands of potential customers with information, links to your web site, or directly with YOUR product!
  141. <p><app class=ImageTape width=596 height=65 img_dir=../../../DEV/logos speed=10 dir=-10
  142. url1=oracle
  143. url2=progress
  144. url3=gupta
  145. url4=informix
  146. url5=lotus
  147. url6=ingres
  148. >
  149. </b>
  150. <h5>If you have any comments or noticed some abnormal behavior, send us an Email: <A HREF="mailto:cdware@sun.com">cdware@sun.com</A> or call us at (415) 336-3941.</h5>
  151. "@", "@"
  152. <h5><p><A HREF=file:///tmp/httpd/.products/CDware/Help/SMICopyright.html>Copyright</A> 1995 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043 USA.  All rights reserved.</h5><br></pre>
  153. <a href=file:///tmp/httpd/.products/DEV/credits.html>Credits</a>
  154. </b>
  155. </form>
  156. </body>
  157. </html>
  158. .
  159.  
  160. format INDEX_DEFAULT =
  161. <html>
  162. <title>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< </title>
  163. $Company
  164. <body>
  165. <center><img ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/sample.gif"></center>
  166. <center><app class="DancingText" font=TimesRoman30b text="This is an example of a main page!" time=2000 pause=1500></center>
  167. <h1>@*
  168. $Company
  169. </h1><p>@*
  170. $Description
  171. <h4>@*
  172. $Product
  173. : You could indicate here the description of your product(s)</h4>
  174. <p>You can create other HTML pages that people will access through this page, to provide details about your products, prices, distributors, events where your company will be present....</p>
  175. <hr><b>
  176. @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  177. $Company
  178. </b><br>Street number and name<br>
  179. City, St Zip<br>
  180. Country.<br>
  181. Phone: (area)....<br>
  182. Fax: (area)...<br>
  183. <h5>To contact our sales services or ask for more information:<A HREF="mailto:@*
  184. $Email
  185. ">@*
  186. $Email
  187. </A></H5>
  188. <h5>To visit our web site:<A HREF="http://@*
  189. $WebSite
  190. ">http://@*
  191. $WebSite
  192. /</A></H5>
  193. <body><html>
  194. .
  195.  
  196. format ADVICES =
  197. <H2><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_pink.gif"><a href="file://@*
  198. "$HomeDir/$HomeName"
  199. ">To test your main page and links</a></H2><br>
  200. <ul><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif">To change your pages, you need to edit the html files that you put in the "@*
  201. $HomeDir
  202. " directory or one of its subdirectories. To do that, you can either use a text editor to directly change the content of the file or one of the numerous tools that exist.
  203. <p><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif">If you visit your html pages, you can come back any time to the main menu of the Developer's Kit by using the "<b>Goto</b>" Menu.<br>
  204. <p><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif">If a link or an image doesn't work when you visit it, it might be because the <b>path</b> you set is incorrect. The correct types of paths are:<br>
  205. <ul>
  206. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Relative path</b>: images/test.gif or ../docs/toc.html<br>
  207. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Web address</b>: http://www.sun.com/index.html or http://www.xm.com/cafe/<br>
  208. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Absolute path (using the http server)</b>: http://localhost:7999/DIRNAME/welcome.htm or http://localhost:7999/DIRNAME/images/test.gif, where DIRNAME is the name of your company directory.<br>
  209. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Absolute path (using the file server)</b>: file:///tmp/httpd/.products/DIRNAME/welcome.html or file:///tmp/httpd/.products/DIRNAME/images/test.gif.<br>
  210. </ul>
  211. </ul><br>
  212. #<H2><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_pink.gif"><a href="file:///tmp/httpd/.products/DEV/tips.html">Help and tips for designing your insertion</a></H2></ul><br>
  213. <H2><IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_pink.gif"><a href="http://localhost:7999/cgi-bin/visit_html.pl#TIPS">Help and tips for designing your insertion</a></H2></ul><br>
  214. .
  215.  
  216. format SUBPAGE =
  217. <hr>
  218. <A NAME="TIPS">
  219. <h1>Tips</h1>
  220. <ol type=1>
  221. #<li><IMG ALIGN=middle SRC="file:///tmp/httpd/.products/DEV/images/u_constr.gif"><a href="file:///tmp/httpd/.products/DEV/maps.html">How to use links with area of images</a><br>
  222. #<li><IMG ALIGN=middle SRC="file:///tmp/httpd/.products/DEV/images/u_constr.gif"><a href="http://localhost:7999/cgi-bin/visit_html.pl#MAPS">How to use links with area of images</a><br>
  223. <li><a href="http://localhost:7999/cgi-bin/visit_html.pl#MAPS">How to use links with area of images</a><br>
  224. #<li><IMG ALIGN=middle SRC="file:///tmp/httpd/.products/DEV/images/u_constr.gif"><a href="file:///tmp/httpd/.products/DEV/applets.html">Where to get Applets</a><br>
  225. <li><a href="http://www.sun.com/styleguide/">Style guide for HTML pages</a>
  226. #<li><a href="http://localhost:7999/cgi-bin/visit_html.pl#TRANS">How to use transparent images</a><br>
  227. </ol>
  228. </b>
  229. <hr>
  230. <A NAME="MAPS">
  231. <h1>How to use links with area of images</h1>
  232. It is possible to use <b>maps</b>. These allow you to go to a new page by clicking on some areas of an image. You need to follow these steps:
  233. <ol>
  234. <li>Insert in your HTML file a reference to your image and a <i>mapfile</i>. (ex:<br>
  235. <ul><tt><A HREF="http://localhost:7999/cgi-bin/imagemap/DIRNAME/test.map"> <IMG SRC="./test.gif" ISMAP></tt><br>
  236. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif"><b>You need to use an absolute path using the http server!</b><br></ul>
  237. <li>create your mapfile. You need to indicate a default URL, and the areas that you want the user to reach. (ex:
  238. <ul><br>
  239. <tt>default file:///tmp/httpd/.products/DIRNAME/index.html<br>
  240. rect    file:///tmp/httpd/.products/DIRNAME/URL1.html  28,669 92,701<br>
  241. rect    file:///tmp/httpd/.products/DIRNAME/URL2.html 98,669 195,703<br>
  242. poly    file:///tmp/httpd/.products/DIRNAME/URL3.html 439,328 466,288 485,302 453,333<br>
  243. circle    file:///tmp/httpd/.products/DIRNAME/URL4.html 299,153 397,153<br>
  244. </tt>
  245. </ul>
  246. </ol>
  247. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/finger.gif">In maps files, you need to use <b><i>absolute paths</b></i>, such as:<br>
  248. <ul>
  249. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Absolute path (using the http server)</b>: http://localhost:7999/DIRNAME/welcome.htm or http://localhost:7999/DIRNAME/images/test.gif, where DIRNAME is the name of your company directory.<br>
  250. <IMG ALIGN=middle src="file:///tmp/httpd/.products/DEV/images/bullet_ball_green.gif"><b>Absolute path (using the file server)</b>: file:///tmp/httpd/.products/DIRNAME/welcome.html or file:///tmp/httpd/.products/DIRNAME/images/test.gif.<br>
  251. </ul>
  252. <A NAME="TRANS">
  253. #<h1>How to use transparent images</h1>
  254. #It is possible to use <b>maps</b>. These allow you to go to a new page by clicking on some areas of an image. You need to follow these steps:
  255. </body>
  256. </html>
  257. .
  258.